package easyexcel.handler;

import com.alibaba.excel.metadata.data.DataFormatData;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;

/**
 * @author ZH
 * 通用样式
 */
public class ExcelCommonStyleHandler {
	public static HorizontalCellStyleStrategy init(){
		WriteCellStyle headWriteCellStyle = new WriteCellStyle();
		// 设置头字体
		WriteFont headWriteFont = new WriteFont();
		headWriteFont.setFontHeightInPoints((short)14);
		// 字体加粗
		headWriteFont.setBold(false);
		headWriteCellStyle.setWriteFont(headWriteFont);
		// 设置头居中
		headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
		// 内容策略
		WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
		// 设置内容字体
		WriteFont contentWriteFont = new WriteFont();
		contentWriteFont.setFontHeightInPoints((short)14);
		contentWriteFont.setFontName("宋体");
		contentWriteCellStyle.setWriteFont(contentWriteFont);
		// 设置 水平居中
		contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
		// 设置 垂直居中
		contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
		return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
	}
}
